package com.itheima.collection.traversal;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author Anomaly
 * @date 2022/12/31 20:31
 */
public class IterDemo {
    public static void main(String[] args) {
        Collection<String> collection = new ArrayList<>();

        collection.add("China");
        collection.add("USA");
        collection.add("JAP");

        Iterator<String> iterator = collection.iterator();

//        System.out.println(iterator.next());
//        System.out.println(iterator.next());
//        System.out.println(iterator.next());

        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
